#include <iostream>
#include <iomanip>
#include "Product.h"

using namespace std;
using namespace Homework;

namespace Homework
{
Product::Product(void)
{
	food[LAYS].quantity = 10;
	food[LAYS].price = .90;

	food[SKITTLES].quantity = 15;
	food[SKITTLES].price = .75;

	food[TWIX].quantity = 5;
	food[TWIX].price = .75;

	food[TRAILMIX].quantity = 4;
	food[TRAILMIX].price = 1.00;

	food[GUM].quantity = 20;
	food[GUM].price = .50;

	food[MINTS].quantity = 25;
	food[MINTS].price = .50;

	names[0] = "Lays";
	names[1] = "Skittles";
	names[2] = "Twix";
	names[3] = "Trailmix";
	names[4] = "Gum";
	names[5] = "Mints";
}

Product::~Product()
{
}

int Product::CheckProduct(int i) {
	try
	{
		if(	food[(Homework::PType)i].quantity == 0 )
		{
			throw 0;
		}
	}
	catch(int n)
	{
		return 0;
	}

	return 1;
}

void Product::getProductInfo(int info)
{
	cout  << names[info] << " cost " << setprecision(3) << food[(Homework::PType)info].price << endl;
}
}